<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/10/28
 * Time: 16:12
 */

namespace app\api\model\Sns;


use app\api\model\User\UserModel;
use think\Model;

class SnsModel extends Model
{
    /**
     * 数据表名 好友关系表
     * @var string
     */
    protected $name = "sns";

    /**
     * @return \think\model\relation\HasOne
     * 我的关注
     */
    public function user()
    {
        return $this->hasOne(UserModel::class, 'id', 'sns_tomid')->field('id,head_img,nickname,sn');
    }

    /**
     * @return \think\model\relation\HasOne
     * 我的粉丝
     */
    public function users()
    {
        return $this->hasOne(UserModel::class, 'id', 'sns_frommid')->field('id,head_img,nickname,sn');
    }
}